#include "../src/sql/SingletonConnectionPool.h"
#include <cppconn/statement.h>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    auto &pool = ConnectionPool::getInstance();
    pool.init("127.0.0.1", 3306, "root", "123456", "db1", 8, 1000);
    std::cout << pool.getQueueSize() << std::endl;
    while(1)
    {
        auto conn = pool.getConnection();
        auto conn1 = pool.getConnection();
        auto *stmt = conn->createStatement();
        std::cout << pool.getQueueSize() << std::endl;
        auto *res = stmt->executeQuery("SELECT * FROM user");
        while (res->next())
        {
            auto name = res->getString("name");
            std::cout << name << std::endl;
        }
        std::cout << pool.getQueueSize() << std::endl;
        res->close();
        stmt->close();
    }
    std::cout << pool.getQueueSize() << std::endl;
    return 0;
}